home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 May / Macworld (1999-05).dmg / Demo⁄free XPress XTensions / XPressImage demo / AppleScripts / XPressImage.HotFolder.as next >
Text File  |  1999-02-22  |  2KB  |  45 lines

  1. -- checkFolder() - This function (or "subroutine") watches a folder
  2. -- for files. If someone has dropped files into the folder, then
  3. -- this function will process the file and move it to the out folder. 
  4. -- but be careful to check to see if the files are finished copying into 
  5. -- FolderToWatch before acting on them. 
  6. -- ------------------------------------------------------------
  7.  
  8. property FolderToWatch : "Macintosh HD:XpressImageHot:" -- insert your folder path name here
  9. property FolderToPut : "Macintosh HD:XpressImageHot:" -- insert your folder path name here
  10. property numFiles : "" -- number of files in folder
  11. property theContents : {} -- contents of folder
  12. property oldContents : {} -- contents of folder
  13. -- ----------------subroutine-----------------------------------
  14. on run
  15.     idle of me
  16. end run
  17.  
  18. -- Does FolderToWatch have files in it?
  19. -- If it does, then we give a green light. 
  20. on idle
  21.     set theContents to list folder FolderToWatch
  22.     set folderStatusChanged to true
  23.     tell application "Finder"
  24.         set numFiles to the number of files in folder FolderToWatch
  25.         if numFiles = 0 then
  26.             set folderStatusChanged to false
  27.         end if
  28.     end tell
  29.     if folderStatusChanged = true then
  30.         repeat with x in theContents
  31.             if x is not in oldContents then
  32.                 set oldContents to oldContents & x & return
  33.                 set theFile to FolderToWatch & x
  34.                 tell application "QuarkXPress™"
  35.                     activate
  36.                     open alias theFile use doc prefs yes
  37.                     GLUON XpressImage "1,3,5"
  38.                     close document 1
  39.                 end tell
  40.             end if
  41.         end repeat
  42.     end if
  43.     oldContents = theContents
  44.     return 1 * 10
  45. end idle